import instance from "@/utils/axios";

const tuijian = () => {
    return instance({
        url: '/v1_0/user/channels',
        method:'get'
    })
}

export { tuijian }


const getwenzhang = ({channel_id, timestamp}) => {
    return instance({
        url: '/v1_1/articles',
        method: 'get',
        params: {
            channel_id,
            timestamp,
            with_top: 1, //是否需要置顶，给1即可
        }
    })
}

export { getwenzhang }

const getwzxq = id => {
    return instance({
        url: '/v1_0/articles/' + id,
        method:'get'
    })

}

export { getwzxq }

// 关注与取消关注
const guanzhu = ({target}) => {
    return instance({
        url: '/v1_0/user/followings',
        method: 'post',
        data:{target}
    })
}

const qxguanzhu = target => {
    return instance({
        url: '/v1_0/user/followings/' + target,
        method:'delete'
    })
}

export { guanzhu, qxguanzhu }


// 点赞与取消点赞
const dianzan = ({target}) => {
    return instance({
        url: '/v1_0/article/likings',
        method: 'post',
        data:{target}
    })
}

const qxdianzan = target => {
    return instance({
        url: '/v1_0/article/likings/' + target,
        method:'delete'
    })
}

export { dianzan, qxdianzan }

//不喜欢与qx不喜欢
const bxihuan = ({target}) => {
    return instance({
        url: '/v1_0/article/dislikes',
        method: 'post',
        data:{target}
    })
}

const qxbxihuan = target => {
    return instance({
        url: '/v1_0/article/dislikes/'+target,
        method: 'delete',
    })
}

export{bxihuan,qxbxihuan}

// 搜索
const sous = q => {
    return instance({
        url: '/v1_0/suggestion',
        method: 'get',
        params: {
            q
        }
    })
}

export { sous }

// 搜索历史记录
const sousjl = () => {
    return instance({
        url: '/v1_0/search/histories',
        method:'get'
    })
}

const scsousjl = () => {
    return instance({
        url: '/v1_0/search/histories',
        method:'delete'
    })
}

export { sousjl, scsousjl }

// 获取搜索结果
const sousjg = q => {
    return instance({
        url: '/v1_0/search',
        method: 'get',
        params: {
            q
        }
    })  
}

export {sousjg}